<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>


    <footer th:fragment="table">
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">项目简介</div>
                            </div>
                            <div class="widget-body  am-fr">

                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-4">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button type="button" class="am-btn am-btn-default am-btn-success" data-toggle="modal" data-target="#myModal1"
                                                        onclick="insert()"><span class="am-icon-plus"></span> 新增
                                                </button>
                                                <button type="button" class="am-btn am-btn-default am-btn-danger"
                                                        onclick="del()"><span class="am-icon-trash-o"></span> 删除
                                                </button>
                                                <button type="button" class="am-btn am-btn-default am-btn-warning" data-toggle="modal" data-target="#myimportModal" onclick="lead()"><span class="am-icon-plus"></span> 导入</button>
                                                <button type="button" class="am-btn am-btn-default am-btn-secondary" onclick="derive()"><span class="am-icon-trash-o"></span> 导出</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-form-group tpl-table-list-select">
                                        <select data-am-selected="{btnSize: 'sm'}" id="investstatus"  class="selectOption">
                                            <option value="">请选择</option>
                                            <option value="信用标" th:selected="${investstatus=='信用标'}">信用标</option>
                                            <option value="抵押标" th:selected="${investstatus=='抵押标'}">抵押标</option>
                                            <option value="债务标" th:selected="${investstatus=='债务标'}">债务标</option>
                                            <option value="飞鸽标" th:selected="${investstatus=='飞鸽标'}">飞鸽标</option>
                                        </select>
                                        <select data-am-selected="{btnSize: 'sm'}" id="pagesize"  class="selectOption">
                                            <option value="">请选择</option>
                                            <option value="5" th:selected="${pagesize==5}">5</option>
                                            <option value="10" th:selected="${pagesize==10}">10</option>
                                            <option value="10" th:selected="${pagesize==15}">15</option>
                                            <option value="10" th:selected="${pagesize==20}">20</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="date" class="am-form-field" th:value="${#dates.format(predate,'yyyy-MM-dd')}" id="predate">
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="date" class="am-form-field " th:value="${#dates.format(nextdate,'yyyy-MM-dd')}" id="nextdate">
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="text" class="am-form-field " id="investkeyword" th:value="${investkeyword}">
                                        <span class="am-input-group-btn">
                                         <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"
                                                 type="button" th:onclick="|page('${allinvest.pageNum}')|"></button>
                                    </span>
                                    </div>
                                </div>

                                <div class="am-u-sm-12">
                                    <div style="overflow-x:scroll">
                                        <table class="am-table am-table-compact am-table-striped tpl-table-black "
                                               id="example-r" style="width: 2000px">
                                            <thead>
                                            <tr>
                                                <th>
                                                    <button onclick="reSelect()"
                                                            class="am-btn  am-btn-default am-btn-success tpl-table-list-field"
                                                            type="button">反选
                                                    </button>
                                                </th>
                                                <th>编号</th>
                                                <th>项目名称</th>
                                                <th>项目总金额</th>
                                                <th>起投资金</th>
                                                <th>年收益率</th>
                                                <th>用户投资期限</th>
                                                <th>项目投资月份</th>
                                                <th>项目发布日期</th>
                                                <th>项目还款日期</th>
                                                <th>保障级别</th>
                                                <th>项目资金余额</th>
                                                <th>项目进度</th>
                                                <th>项目剩余天数</th>
                                                <th>每万元收益</th>
                                                <th>还款方式</th>
                                                <th>保障机构</th>
                                                <th>公司</th>
                                                <th>风控信用等级</th>
                                                <th>项目类型</th>
                                                <th>项目状态</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr class="gradeX" th:each="invest,s : ${allinvest.list}">
                                                <td><input type="checkbox" name="persons" th:value="${invest.investId}" class="choice"></td>
                                                <td th:text="${invest.investNumber}">编号</td>
                                                <td th:text="${invest.investName}">项目名称</td>
                                                <td th:text="${invest.investAmount}">项目总金额</td>
                                                <td th:text="${invest.investStartpay}">起投资金</td>
                                                <td th:text="${invest.investGetyearmoney}">年收益率</td>
                                                <td th:text="${invest.investDay}">用户投资期限</td>
                                                <td th:text="${invest.investDeadline}">项目投资月份</td>
                                                <td th:text="${#dates.format(invest.investReleasetime,'yyyy-MM-dd')}">项目发布日期</td>
                                                <td th:text="${#dates.format(invest.investPaytime,'yyyy-MM-dd')}">项目还款日期</td>
                                                <td th:text="${invest.investStafguard}">保障级别</td>
                                                <td th:text="${invest.investBalance}">项目资金余额</td>
                                                <td th:text="${invest.investSubsribe}">项目进度</td>
                                                <td th:text="${invest.investRemaindertime}">项目剩余天数</td>
                                                <th th:text="${invest.investGetmonofyear}">每万元收益</th>
                                                <th th:text="${invest.repayName}">还款方式</th>
                                                <th th:text="${invest.stafguardName}">保障机构</th>
                                                <th th:text="${invest.companyName}">公司</th>
                                                <th th:text="${invest.riskPingname}">风控信用等级</th>
                                                <th th:text="${invest.typeName}">项目类型</th>
                                                <th th:text="${invest.statusName}">项目状态</th>
                                                <td>
                                                    <div class="tpl-table-black-operation">
                                                        <a href="javascript:;" data-toggle="modal" data-target="#myModal2" th:onclick="|findmost('${invest.investId}')|" >更多公司信息</a>
                                                        <a href="javascript:;" data-toggle="modal" data-target="#myModal2" th:onclick="|findmost2('${invest.investId}')|" >查看招标公司还款详情</a>
                                                        <a href="javascript:;" data-toggle="modal" data-target="#myModal2" th:onclick="|findmost3('${invest.investId}')|" >查看公司的风控信息</a>
                                                        <a href="javascript:;" data-toggle="modal" data-target="#myModal2" th:onclick="|findmost4('${invest.investId}')|" >查看本项目的评论</a>
                                                        <a href="javascript:;" class="tpl-table-black-operation-del">
                                                            <i class="am-icon-trash" th:onclick="|delone('${invest.investId}')|"></i> 删除
                                                        </a>
                                                    </div>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="am-u-lg-12 am-cf">
                                        <div class="am-u-lg-3">
                                            跳转至:<input type="number" id="num"  class="selectOption">/ 页
                                            <span>
                                            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="button" th:onclick="findpage()"></button>
                                        </span>
                                        </div>

                                        <div class="am-fr">
                                            <ul class="am-pagination tpl-pagination">
                                                <li ><a href="javascript:" th:onclick="|page('${allinvest.navigateFirstPage}')|">首页</a></li>
                                                <li  th:if="allinvest.hasPreviousPage"><a href="javascript:" th:onclick="|page('${allinvest.prePage}')|">«</a></li>


                                                <li th:each="pageNum:${#numbers.sequence(1,allinvest.pages)}">
                                                    <a th:text="${pageNum}" th:onclick="|page('${pageNum}')|"></a>
                                                </li>


                                                <li th:if="allinvest.hasNextPage"><a href="javascript:" th:onclick="|page('${allinvest.nextPage}')|">»</a></li>
                                                <li><a href="javascript:" th:onclick="|page('${allinvest.navigateLastPage}')|">尾页</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="margin-top: 100px">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">增加项目</h4>
                        </div>
                        <div id="model">
                            <form>
                                项目名称:<input type="text" id="investName"><br />
                                项目起投金额:<input type="text" id="investStartPay"><br/>
                                用户投资期限:<input type="text" id="investDay"><br/>
                                项目投资总金额:<input type="text" id="investAmount"><br/>
                                项目投资期限:<input type="text" id="investDeadline"><br/>
                                发布日期:<input type="date" id="pretime"><br/>
                                还款日期:<input type="date" id="nexttime"><br/>
                                保障级别:<input type="text" id="investstafguard"><br/>
                                投资项目天数:<input type="text" id="day"><br/>
                                <select  id="insertRepay" >
                                    <option value="">请选择</option>
                                    <option th:value="${rep.repayId}" th:text="${rep.repayName}" th:each="rep : ${insertRepay}"></option>
                                </select><br />
                                <select  id="insertstaf" >
                                    <option value="">请选择</option>
                                    <option th:value="${srep.stafguardId}" th:text="${srep.stafguardName}" th:each="srep : ${insertstaf}"></option>
                                </select><br />
                                <select  id="insertCompany" >
                                    <option value="">请选择</option>
                                    <option th:value="${crep.companyId}" th:text="${crep.companyName}" th:each="crep : ${insertCompany}"></option>
                                </select><br />
                                <select  id="insertRisk" >
                                    <option value="">请选择</option>
                                    <option th:value="${rrep.riskId}" th:text="${rrep.riskPingname}" th:each="rrep : ${insertRisk}"></option>
                                </select><br />
                                <select  id="insertStatus" >
                                    <option value="">请选择</option>
                                    <option th:value="${srep.statusId}" th:text="${srep.statusName}" th:each="srep : ${insertStatus}"></option>
                                </select><br />
                                <select  id="investType" >
                                    <option value="">请选择</option>
                                    <option th:value="${trep.typeId}" th:text="${trep.typeName}" th:each="trep : ${investType}"></option>
                                </select>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" th:onclick="subload()">提交</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>



            <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true" style="margin-top: 100px">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel2">查看充值更多信息</h4>
                        </div>
                        <div style="text-align: center" id="comdetail">
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>

            <input type="hidden" id="allid" th:value="${ids}">
            <!--导入模态框-->
            <div class="modal fade" id="myimportModal" tabindex="-1" role="dialog" aria-labelledby="myimportModalLabel" aria-hidden="true" style="margin-top: 300px">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myimportModalLabel">查看充值更多信息</h4>
                        </div>
                        请选择需要上传的文件：<input type="file" name="file" id="importfile">
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="importscore()">提交</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>

        </div>
    </footer>
    <script>



        /*反选*/
        function reSelect() {
            var allids=$('#allid').val().split(',')
            var allid=[]
            allid.push(parseInt(allids[0].split('')[1]))
            for(var i=1;i<allids.length;i++){
                allid.push(parseInt(allids[i]))
            }
            for(var i=0;i<inv.length;i++){
                for (var j=0;j<allid.length;j++){
                    if(allid[j]==inv[i]){
                        allid.splice(j,1)
                    }
                }
            }
            inv=allid
            $("input[name='persons']").each(function () {
                $(this).prop("checked",!$(this).prop("checked"))
            })
        }

        function page(i) {
            $.ajax({
                url:"/p2p/projectbreif/getallprojectbreif",
                data:{
                    "investstatus":$("#investstatus").val(),
                    "predate":$("#predate").val(),
                    "nextdate":$("#nextdate").val(),
                    "investkeyword":$("#investkeyword").val(),
                    "pagenum":i,
                    "pagesize":$("#pagesize").val(),
                },
                type:"get",
                dataType:"html",
                success:function (data) {
                    $("#content").html(data)
                }
            })
        }


        function findpage() {
            var pagesnum=$('#num').val();
            page(pagesnum);
        }


        $(".choice").click(function () {
            if($(this).prop("checked")){
                if(!($(this).val() in inv)){
                    inv.push($(this).val())
                }
            }else if(!$(this).prop("checked")){
                for (var i=0;i<inv.length;i++){
                    if(inv[i]===$(this).val()){
                        inv.splice(i,1);
                    }
                }
            }
        })

        /*导出*/
        function derive() {
            if(inv.length>0){
                location.href="/p2p/projectbreif/projectbreifderive?ids="+inv
            }else{
                alert("请先选择！")
            }
        }

        /*导入*/
        function lead() {
            var form = new FormData();
            form.append("file", document.getElementById("importfile").files[0]);
            $.ajax({
                url:"/p2p/projectbreif/importProjectbreif",
                data:form,
                type:"post",
                dataType:"text",
                processData: false,
                contentType: false,
                success:function (data) {
                    if(data==1){
                        $.ajax({
                            url:"/p2p/projectbreif/getallprojectbreif",
                            type:"get",
                            dataType:"html",
                            success:function (data) {
                                $("#content").html(data)
                            }
                        })
                    }else{
                        alert("导入失败")
                    }
                },
            })
        }

        //删除单个
        function delone(i) {
            $.ajax({
                url:"/p2p/projectbreif/deloneprojectbreif",
                data:{
                    "id":i,
                },
                type:"get",
                dataType:"html",
                success:function (data) {
                    page(1);
                    $("#content").html(data)
                }
            })
        }


        //增加
        function subload() {
            $.ajax({
                url:"/p2p/projectbreif/insertProjectBreif",
                data:{
                "investName":$("#investName").val(),
                "investStartPay":$("#investStartPay").val(),
                "investDay":$("#investDay").val(),
                "investAmount":$("#investAmount").val(),
                "investDeadline":$("#investDeadline").val(),
                "pretime":$("#pretime").val(),
                "nexttime":$("#nexttime").val(),
                "investstafguard":$("#investstafguard").val(),
                "day":$("#day").val(),
                "insertRepay":$("#insertRepay").val(),
                "insertstaf":$("#insertstaf").val(),
                "insertCompany":$("#insertCompany").val(),
                "insertRisk":$("#insertRisk").val(),
                "insertStatus":$("#insertStatus").val(),
                "investType":$("#investType").val(),
                },
                type:"get",
                dataType:"text",
                success:function (data) {
                    if(data==1){
                        alert("恭喜添加成功");
                        page(1);
                    }else {
                        alert("抱歉,添加失败!");
                    }
                }
            })
        }

        //批量删除
        function del() {
            var ides=inv;
            $.ajax({
                url:"/p2p/projectbreif/delselectedprojectbreif",
                data:{
                    "id":ides,
                },
                type:"get",
                dataType:"html",
                success:function (data) {
                    page(1);
                    inv=[];
                    $("#content").html(data)
                }
            })
        }


        function findmost(i) {
            $.ajax({
                url: "/p2p/projectbreif/getcomdetail",
                data:{"id":i},
                type: "get",
                dataType:"json",
                success:function (data) {
                    console.log(data)
                    var s="";
                    s+="<div class=\"modal-body\">\n" +
                        "公司名称:<div>"+data.companyName+"</div>\n" +
                        "公司注册时间:<div>"+data.companyTime+"</div>\n" +
                        "公司地址:<div>"+data.companyAddress+"</div>\n" +
                        "公司行业:<div>"+data.companyType+"</div>\n" +
                        "公司管理信息:<div>"+data.companyManagestatus+"</div>\n" +
                        "公司财务信息:<div>"+data.companyMoneystatus+"</div>\n" +
                        "\n" +
                        "</div>"
                    $('#comdetail').html(s)
                },
            })
        }



        function findmost2(i) {
            $.ajax({
                url: "/p2p/projectbreif/getcomdetail",
                data:{"id":i},
                type: "get",
                dataType:"json",
                success:function (data) {
                    console.log(data)
                    var s="";
                    s+="<div class=\"modal-body\">\n" +
                        "公司名称:<div>"+data.companyName+"</div>\n" +
                        "公司注册时间:<div>"+data.companyTime+"</div>\n" +
                        "公司地址:<div>"+data.companyAddress+"</div>\n" +
                        "公司行业:<div>"+data.companyType+"</div>\n" +
                        "公司管理信息:<div>"+data.companyManagestatus+"</div>\n" +
                        "公司财务信息:<div>"+data.companyMoneystatus+"</div>\n" +
                        "\n" +
                        "</div>"
                    $('#comdetail').html(s)
                },
            })
        }



        function findmost3(i) {
            $.ajax({
                url: "/p2p/projectbreif/getcomdetail",
                data:{"id":i},
                type: "get",
                dataType:"json",
                success:function (data) {
                    console.log(data)
                    var s="";
                    s+="<div class=\"modal-body\">\n" +
                        "公司名称:<div>"+data.companyName+"</div>\n" +
                        "公司注册时间:<div>"+data.companyTime+"</div>\n" +
                        "公司地址:<div>"+data.companyAddress+"</div>\n" +
                        "公司行业:<div>"+data.companyType+"</div>\n" +
                        "公司管理信息:<div>"+data.companyManagestatus+"</div>\n" +
                        "公司财务信息:<div>"+data.companyMoneystatus+"</div>\n" +
                        "\n" +
                        "</div>"
                    $('#comdetail').html(s)
                },
            })
        }



        function findmost4(i) {
            $.ajax({
                url: "/p2p/projectbreif/getcomdetail",
                data:{"id":i},
                type: "get",
                dataType:"json",
                success:function (data) {
                    console.log(data)
                    var s="";
                    s+="<div class=\"modal-body\">\n" +
                        "公司名称:<div>"+data.companyName+"</div>\n" +
                        "公司注册时间:<div>"+data.companyTime+"</div>\n" +
                        "公司地址:<div>"+data.companyAddress+"</div>\n" +
                        "公司行业:<div>"+data.companyType+"</div>\n" +
                        "公司管理信息:<div>"+data.companyManagestatus+"</div>\n" +
                        "公司财务信息:<div>"+data.companyMoneystatus+"</div>\n" +
                        "\n" +
                        "</div>"
                    $('#comdetail').html(s)
                },
            })
        }
















    </script>
</head>
</html>
